package com.nz.net.hays.www;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TableRow;


public class LocationActivity extends Activity implements OnClickListener, OnCheckedChangeListener{

	String location="";
	Intent intent;
	Button done;
	CheckBox checkbox_northisland,checkbox_allauckland,checkbox_aucklandcbd,checkbox_northauckland;
	CheckBox checkbox_southauckland,checkbox_wellington,checkbox_allsouthland,checkbox_christchurch;
	CheckBox checkbox_regional,checkbox_dunedin;
	@SuppressWarnings("deprecation")
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
	super.onCreate(savedInstanceState);
	 intent = getIntent();
	// set view to activity_location.xml
	setContentView(R.layout.activity_location);
	
	// enabling checkboxes
	 checkbox_northisland= (CheckBox)findViewById(R.id.checkbox_allnorthisland);
	 checkbox_allauckland= (CheckBox)findViewById(R.id.checkbox_allauckland);
	 checkbox_aucklandcbd= (CheckBox)findViewById(R.id.checkbox_aucklandcbd);
	 checkbox_northauckland= (CheckBox)findViewById(R.id.checkbox_northauckland);
	 checkbox_southauckland= (CheckBox)findViewById(R.id.checkbox_southauckland);
	 checkbox_wellington= (CheckBox)findViewById(R.id.checkbox_wellington);
	 checkbox_allsouthland= (CheckBox)findViewById(R.id.checkbox_allsouthland);
	 checkbox_christchurch= (CheckBox)findViewById(R.id.checkbox_christchurch);
	 checkbox_dunedin= (CheckBox)findViewById(R.id.checkbox_dunedin);
	 checkbox_regional= (CheckBox)findViewById(R.id.checkbox_regional);
	 done= (Button)findViewById(R.id.buttondone);
	 
	
	
	 done.setOnClickListener(this);
	 checkbox_northisland.setOnClickListener(this);
	checkbox_allauckland.setOnClickListener(this);
	checkbox_aucklandcbd.setOnClickListener(this);
	checkbox_christchurch.setOnClickListener(this);
	checkbox_dunedin.setOnClickListener(this);
	checkbox_northauckland.setOnClickListener(this);
	checkbox_regional.setOnClickListener(this);
	checkbox_southauckland.setOnClickListener(this);
	checkbox_wellington.setOnClickListener(this);
	checkbox_allsouthland.setOnClickListener(this);
	
	checkbox_allauckland.setMovementMethod(new ScrollingMovementMethod());
	
	int Array_Count=0;
	String[] Str_Array = {"Gold","Diamond","Platinum"}; 

	Array_Count=Str_Array.length;
	//Array_Count=3;
	FrameLayout my_layout = (FrameLayout)findViewById(R.id.container);

	for (int i = 0; i < Array_Count; i++) 
	{
	    TableRow row =new TableRow(this);
	    row.setId(i);
	    row.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
	    CheckBox checkBox = new CheckBox(this);
	    checkBox.setOnCheckedChangeListener(this);
	    checkBox.setId(i);
	    checkBox.setText(Str_Array[i]);
	    row.addView(checkBox);  
	    my_layout.addView(row);
	 
	}
	
	}

	@Override
	public void onClick(View v) {

		if (checkbox_allauckland.isChecked())
		{
			location=""+ checkbox_allauckland.getText();
			// "com.nz.net.hays.www.MainActivity"
		  // Intent i = new Intent(getApplicationContext(),MainActivity.class);		
			//i.putExtra("location",location);
			//startActivity(i);
		}
		if (checkbox_aucklandcbd.isChecked())
		{
			location=location+checkbox_aucklandcbd.getText();
			// "com.nz.net.hays.www.MainActivity"
		  
		}
		if(done.isPressed())
		{
			 Intent mainActivity = new Intent(getApplicationContext(),MainActivity.class);		
			 mainActivity.putExtra("location",location);
				startActivity(mainActivity);
		
		}
		
	}

	@Override
	public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
		// TODO Auto-generated method stub
		
	}
	
	
	
}
